<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MVCWeb.Models.ViewData.CommunityNewViewData>" %>

<%@ Register Src="~/Views/Menu/MainMenu.ascx" TagName="MainMenu" TagPrefix="mmuc" %>

<%@ Register Src="~/Views/Shared/LogOnUserControl.ascx" TagName="LogOnUserControl" TagPrefix="louc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Edit community</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript" language="javascript">

        $(document).ready(function() {
            $("#CommunityForm").validate({
                rules:
            {
                Name:
                {
                    required: true
                }
            },
                messages:
            {
                Name:
                {
                    required: "Name must be entered"
                }
            }
            });
            $("#submit_view").click(function() {
                $("#IsRedirectToView").val("true");
            });
        });
    </script>

    <louc:LogOnUserControl ID="LogOnUserControl1" runat="server" />
    <!-- BEGIN: MainMenu -->
    <mmuc:MainMenu ID="MainMenu1" runat="server" />
    <!-- END: MainMenu -->
    <br />
    <br />
    <%= Html.ValidationSummary() %>
    <% using (Html.BeginForm("Edit", "Community", FormMethod.Post, new { id = "CommunityForm", enctype = "multipart/form-data" }))
       {%>
    <fieldset>
        <legend>Edit community</legend>
        <p>
            <label for="Name">
                Community Name:</label>
            <%= Html.TextBox("Name", ViewData.Model.Community.Name)%>
            <%= Html.ValidationMessage("Name", "*") %>
        </p>
        <p>
            <label for="Desc">
                Description:</label>
            <%= Html.TextArea("Desc", ViewData.Model.Community.Desc) %>
            <%= Html.ValidationMessage("Desc", "*") %>
        </p>
        <p>
            <label for="CompanyId">
                Company:</label>
            <%= Html.DropDownList("CompanyId", new SelectList(ViewData.Model.Companies, "CompanyId", "Name", ViewData.Model.Community.CompanyId))%>
            <%= Html.ValidationMessage("CompanyId", "*") %>
        </p>
        <p>
            <label for="FullPath">
                File for Image:</label>
            <input type="file" name="FullPath" id="FullPath" size="34" />
            <%= Html.ValidationMessage("FullPath", "*")%>
        </p>
        <p>
            <label for="UserId">
                User:</label>
            <%= Html.DropDownList("UserId", new SelectList(ViewData.Model.Users, "UserId", "LoginId", ViewData.Model.Community.UserId))%>
            <%= Html.ValidationMessage("UserId", "*")%>
        </p>
        <p>
            <label for="NewUserId">
                Or create new User</label>
            <%= Html.TextBox("NewUserId", "")%>
            <%= Html.ValidationMessage("NewUserId", "*")%>
        </p>
        <p>
            <label for="NewUserPassword">
                with password:</label>
            <%= Html.TextBox("NewUserPassword", "")%>
            <%= Html.ValidationMessage("NewUserPassword", "*")%>
        </p>
        <p>
            <label for="ManagerId">
                Manager:</label>
            <%= Html.DropDownList("ManagerId", new SelectList(ViewData.Model.Managers, "UserId", "LoginId", ViewData.Model.Community.ManagerId))%>
            <%= Html.ValidationMessage("ManagerId", "*") %>
        </p>
        <p>
            <label for="NewManagerId">
                Or create new Manager</label>
            <%= Html.TextBox("NewManagerId", "")%>
            <%= Html.ValidationMessage("NewManagerId", "*")%>
        </p>
        <p>
            <label for="NewManagerPassword">
                with password:</label>
            <%= Html.TextBox("NewManagerPassword", "")%>
            <%= Html.ValidationMessage("NewManagerPassword", "*")%>
        </p>
        <br />
        <p>
            <%= Html.Hidden("IsRedirectToView")%>
            <input id="submit" name="submit" type="submit" value="Update" />
            <input id="submit_view" name="submit_view" type="submit" value="Update & View" />            
            <input type="reset" value="Reset" />
        </p>
    </fieldset>
    <% } %>
    <div>
        <%=Html.ActionLink("Go back", "Index") %>
    </div>
</asp:Content>
